/**
 * 对象深度合并
 * @param obj1 
 * @param obj2 
 * @returns 
 */
export function deepMerge(obj1, obj2) {
    const obj = {...obj1}
    for (let key in obj2) {
        // console.log('type1', key, obj1[key], getType(obj1[key]))
        // console.log('type2', key, obj2[key], getType(obj2[key]))
        if (obj1.hasOwnProperty(key) && getType(obj1[key]) === '[object Object]' && getType(obj2[key]) === '[object Object]') {
            obj[key] = deepMerge(obj1[key], obj2[key])
        } else {
            obj[key] = obj2[key]
        }
    }
    return obj
}
/**
 * 获取对象类型
 * @param argument 传入参数 
 * @returns 
 */
export function getType(argument) {
    // {} => "[object Object]"
    // [] => "[object Array]"
    // function(){} => "[object Function]"
    // undefined => "[object Undefined]"
    //  => "[object Undefined]"
    // null => "[object Null]"
    // new Date() => "[object Date]"
    // /at/ => "[object RegExp]"
    return Object.prototype.toString.call(argument)
}
